/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package BusinessLayer;

import com.sun.jersey.core.util.Base64;
import java.sql.Blob;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author zorr
 */
public class Helper {

    private Helper() {
    }

    public static byte[] blob2byte(Blob b) {
        //blob to byte[]
        byte[] allBytesInBlob = null;
        try {
            allBytesInBlob = b.getBytes(1, (int) b.length());
        } catch (SQLException ex) {
            Logger.getLogger(Helper.class.getName()).log(Level.SEVERE, null, ex);
        }
        return allBytesInBlob;
    }

    public static String blob2string64(Blob b) {
        byte[] allBytesInBlob = null;
        try {
            allBytesInBlob = b.getBytes(1, (int) b.length());
        } catch (SQLException ex) {
            Logger.getLogger(Helper.class.getName()).log(Level.SEVERE, null, ex);
        }
        // kodiere byte[] in base64
        String result = new String(Base64.encode(allBytesInBlob));
        return result;
    }
    
    public static Blob byte2blob(byte[] b) {
        return null;
    }
}
